#ifndef PSD_STATS_H
#define PSD_STATS_H

typedef struct psd_conn_stats_t {
	char *session_id;
	char *destination;
	double start_time;
	double duration;
	uint64_t bytes_read;
	uint64_t bytes_written;
	uint64_t bytes_retr;
	float rtt;
} psdConnStats;

typedef struct psd_session_stats_t {
	char *depot;
	char *session_id;
	char *username;
	char *email;
	char *institution;
	char *upstream_conns;
	char *downstream_conns;
	double end_time;
	double duration;
	uint64_t bytes_read;
	uint64_t bytes_written;
	double read_rate;
	double write_rate;
} psdSessionStats;

typedef struct psd_stats_backend_t {
	char *name;
	psdSessionStats **(*read_stats) (double earliest_time, int max_count, int *num_stats);
	int (*save_stats) (psdSessionStats *stats);
} psdStatsBackend;

psdConnStats *psd_conn_stats_alloc();
void psd_conn_stats_free(psdConnStats *stats);
psdSessionStats *psd_session_stats_alloc();
void psd_session_stats_free(psdSessionStats *stats);

int psd_set_stats_backend(psdStatsBackend *stats_be);

int psd_session_save_stats(psdSessionStats *stats);
psdSessionStats **psd_stats_get_session_stats_history(double earliest_time, int max_count, int *num_stats);

#endif
